#pragma once

#include <fcntl.h>

bool SetNonBlockOrDie(int fd)
{
    int fl = fcntl(fd, F_GETFL);
    if (fl == -1)
        return false;
    fl = fcntl(fd, F_SETFL, fl | O_NONBLOCK);
    if (fl == -1)
        return false;
    return true;
}